package com.seu.me.thread.day1.sync005;

/**
 * synchronized的重入
 *
 * @author liangfeihu
 */
public class SyncDubbo1 {

    public synchronized void method1() {
        System.out.println(Thread.currentThread().getName() + " method1..");
        method2();
    }

    public synchronized void method2() {
        System.out.println(Thread.currentThread().getName() + " method2..");
        method3();
    }

    public synchronized void method3() {
        System.out.println(Thread.currentThread().getName() + " method3..");
    }

    public static void main(String[] args) {
        final SyncDubbo1 sd = new SyncDubbo1();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                sd.method1();
            }
        }, "t1");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                sd.method2();
            }
        }, "t2");

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                sd.method3();
            }
        }, "t3");

        t3.start();
        t1.start();
        t2.start();
    }
}
